package com.totem.customer.serivce.auth;

import com.totem.base.security.Authentication;
import com.totem.base.security.model.UsernamepasswordAuthentication;
import com.totem.base.security.model.UsernamepasswordCertification;
import com.totem.customer.model.TCustomers;
import com.totem.customer.serivce.IAuthService;
import com.totem.customer.serivce.ITCustomerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service("nicknameAuthenticationService")
public class NicknameAuthServiceImpl extends UsernamepasswordAuthentication implements IAuthService {
    @Autowired
    private ITCustomerService itCustomerService;
    private Authentication authentication;

    protected UsernamepasswordCertification findByNickname(String nickname) {
        TCustomers tCustomers = itCustomerService.findByNickname(nickname);
        if(tCustomers==null) return null;
        UsernamepasswordCertification another = new UsernamepasswordCertification(tCustomers.getNickname(), tCustomers.getPassword());
        another.setId(tCustomers.getId());
        return another;
    }
}
